package com.my.study.structures.stack;

/**
 * @author Carlos
 * @version 1.0
 * @Description 字符串表达式的转换
 * @date 2021/6/25 7:28
 **/
public abstract class AbstractStringTransform implements ITransformExpression<String, String>, IPriorityValue {

    /**
     * 获取操作符优先级
     *
     * @param operator
     * @return
     */
    @Override
    public int getPriorityValue(String operator) {
        int result;
        switch (operator) {
            case "+":
                result = ADD;
                break;
            case "-":
                result = SUB;
                break;
            case "*":
                result = MUL;
                break;
            case "/":
                result = DIV;
                break;
            default:
                throw new RuntimeException("输入的运算符有误");
        }

        return result;
    }
}
